﻿using CID.Domain.Infrastructure;
using CID.Domain.Operations;
using FluentNHibernate.Mapping;

namespace CID.Domain.Persistence.Mappings.Infrastructure
{
    public class ParameterValueMap : EntityMap<ParameterValue>
    {
        public const string DiscriminatorColumn = "Type";

        public ParameterValueMap() : base()
        {
            Map(x => x.SerializedValue).CustomSqlType("NVARCHAR(MAX)");
            References<Definition>(x => x.Definition);
            References<Parameter>(x => x.Parameter);

            DiscriminateSubClassesOnColumn(DiscriminatorColumn).Length(20);
        }
    }

    public class DefaultParameterValueMap : SubclassMap<DefaultParameterValue>
    {
        public DefaultParameterValueMap()
        {
            DiscriminatorValue("Default");
        }
    }

    public class EnvironmentParameterValueMap : SubclassMap<EnvironmentParameterValue>
    {
        public EnvironmentParameterValueMap()
        {
            DiscriminatorValue("Environment");
            References<Environment>(x => x.Environment);
        }
    }
}
